package cn.edu.wynu.springbootlearn.service.impl;

import cn.edu.wynu.springbootlearn.bean.Movie;
import cn.edu.wynu.springbootlearn.mapper.MovieMapper;
import cn.edu.wynu.springbootlearn.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

// 将当前类注入到IOC容器里面
@Service
public class MovieServiceImpl implements MovieService {

    // 从IOC容器里面寻找一个MovieMapper类型的对象，并放到当前类里面
    @Autowired
    MovieMapper movieMapper;

    @Override
    public List<Movie> queryAllMovie() {
        return movieMapper.allMovie();
    }

    @Override
    public Movie queryMovieById(Integer id) {
        return movieMapper.selectMovieById(id);
    }

    @Override
    public String addMovie(Movie movie) {
        return null;
    }

    @Override
    public String updateMovie(Movie movie) {
        Integer integer = movieMapper.updateMovie(movie);
        if (integer == 1) return "success";
        else return "fail";
    }

    @Override
    public String deleteMovieById(Integer id) {
        return null;
    }
}
